package com.project.controller;

import com.project.bean.BuyerCarBean;
import com.project.bean.ProductBean;
import com.project.service.IBuyerCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("buyerCar")
public class BuyerCarController {

    @Autowired
    private IBuyerCarService buyerCarService;

    @RequestMapping("findById")
    public List<BuyerCarBean> findById(Integer userId) {
        return buyerCarService.findById(userId);
    }



    @RequestMapping("add")
    public String add(String option, ProductBean productBean, Integer num, Integer userId, Integer money) {
        buyerCarService.add(option, productBean, num, userId, money);
        return "ok";
    }

    ;

    @RequestMapping("remove")
    public String remove(Integer buyCarId) {
        buyerCarService.remove(buyCarId);
        return "ok";
    }

    ;

    @RequestMapping("updateNum")
    public String updateNum(Integer buyCarId, Integer num) {
        buyerCarService.updateNum(buyCarId, num);
        return "ok";
    }

    ;
}
